<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input
        type="text"
        placeholder="enter the name you search"
        v-model="IptValue"
      />&nbsp;
      <button @click="SearchHandle">Search</button>
    </div>
  </section>
</template>

<script>
import axios from "axios";
export default {
  name: "Header",
  data() {
    return {
      IptValue: "",
    };
  },
  props: ["getDataList"],
  methods: {
    // 获取数据
    async SearchHandle() {
      this.getDataList({ isUpdate: true, isInit: false });
      const res = await axios.get(
        `https://api.github.com/search/users?q=${this.IptValue}`
      );
      this.getDataList({ isUpdate: false, isData: res.data.items });
    },
  },
};
</script>

<style>
</style>